1.2 Hello, World!

개발 환경 세팅

본격적으로 시작하기 이전에, 편리하게 코드를 작성하기 위한 각종 유틸들을 사용하도록 한다.
https://rust-analyzer.github.io/
rust-analyzer는 LSP를 통해 쉬운 코드 관리 및 보수를 돕는다.

vim에 세팅을 해준다.
첫번째로 서버를 만들어준다.
https://rust-analyzer.github.io/manual.html#rust-analyzer-language-server-binary

mkdir -p ~/.local/bin
curl -L https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer
chmod +x ~/.local/bin/rust-analyzer

os 버전에 맞는 파일을 받고, 명령어로 실행할 수 있도록 만들어준다.
Pasted image 20240429234649.png
제대로 된다면 위 명령어가 제대로 실행될 것이다.

https://github.com/rust-lang/rust.vim
다음으로는 이것을 실행해준다.
위의 anlayzer를 설치해야만 되는 것인지는 명확히 모르겠다.
다만 이 저장소는 rust 공식 vim 플러그인인 모양이다.

유용한 도구

Hello World

위의 내용들은 이후에 다시 다루게 될 것이다.

fn main() {
  println!("Hello, world!");
}

기본적인 함수를 만들어본다.
Pasted image 20240430080950.png
rustc를 통해 컴파일하면, 실행파일이 만들어진다.

println!은 매크로 호출 코드이다.
함수 호출 코드라면 !가 없다.